<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<!-- Mirrored from www.wolfssl.com/wolfSSL/Docs-wolfssl-manual-18-3-wolfcrypt-api-asn.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Jan 2017 13:36:59 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><!-- /Added by HTTrack -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="Generator" content="iWeb 3.0.4"/>
<meta name="iWeb-Build" content="local-build-20170103"/>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<meta name="viewport" content="width=770"/>
<title>wolfSSL - Docs | wolfCrypt Manual - Chapter 18.3 (ASN)</title>
<link rel="stylesheet" type="text/css" media="screen,print" href="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/Docs-wolfssl-manual-18-3-wolfcrypt-api-asn.css"/>
<!--[if lt IE 8]><link rel='stylesheet' type='text/css' media='screen,print' href='Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/Docs-wolfssl-manual-18-3-wolfcrypt-api-asnIE.css'/><![endif]-->
<!--[if gte IE 8]><link rel='stylesheet' type='text/css' media='screen,print' href='Media/IE8.css'/><![endif]-->
<script type="text/javascript" src="Scripts/iWebSite.js"></script>
<script type="text/javascript" src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/Docs-wolfssl-manual-18-3-wolfcrypt-api-asn.js"></script>
<meta name="description" content="wolfSSL - Docs | wolfCrypt Manual - Chapter 18.3 (ASN)"/><meta name="keywords" content="embedded ssl, ssl library, embedded security, openssl alternative, ssl api, ssl, tls, cyassl, openssl replacement, openssl api, ssl functions, small openssl, smart grid, connected home, ecc, lightweight ssl, suite b, encryption security software, ssl inspection"/><meta name="robots" content="follow,index"/> <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','../../www.google-analytics.com/analytics.js','ga');ga('create','UA-64826966-1','auto');ga('send','pageview');</script>
 
<script>//<![CDATA[
window.zEmbed||function(e,t){var n,o,d,i,s,a=[],r=document.createElement("iframe");window.zEmbed=function(){a.push(arguments)},window.zE=window.zE||window.zEmbed,r.src="javascript:false",r.title="",r.role="presentation",(r.frameElement||r).style.cssText="display: none",d=document.getElementsByTagName("script"),d=d[d.length-1],d.parentNode.insertBefore(r,d),i=r.contentWindow,s=i.document;try{o=s}catch(c){n=document.domain,r.src='javascript:var d=document.open();d.domain="'+n+'";void(0);',o=s}o.open()._l=function(){var o=this.createElement("script");n&&(this.domain=n),o.id="js-iframe-async",o.src=e,this.t=+new Date,this.zendeskHost=t,this.zEQueue=a,this.body.appendChild(o)},o.write('<body onload="document._l();">'),o.close()}("../../assets.zendesk.com/embeddable_framework/main.js","wolfssl.zendesk.com");
//]]></script>
  </head>
<body style="background: rgb(255, 255, 255); margin: 0pt; " onload="onPageLoad();">
<div style="text-align: center; ">
<div style="margin-bottom: 20px; margin-left: auto; margin-right: auto; margin-top: 20px; overflow: hidden; position: relative; word-wrap: break-word;  background: rgb(255, 255, 255); text-align: left; width: 770px; " id="body_content">
<div style="float: left; margin-left: 0px; position: relative; width: 770px; z-index: 0; " id="nav_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
<div style="clear: both; height: 0px; line-height: 0px; " class="spacer"> </div>
</div>
<div style="float: left; height: 0px; line-height: 0px; margin-left: 0px; position: relative; width: 770px; z-index: 10; " id="header_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
</div>
<div style="margin-left: 0px; position: relative; width: 770px; z-index: 5; " id="body_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
<div id="id1" style="height: 38px; left: 375px; position: absolute; top: 157px; width: 361px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_361_38" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style">wolfSSL Manual</p>
</div>
</div>
</div>
<div id="id2" style="height: 24px; left: 193px; position: absolute; top: 122px; width: 268px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_268_24" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_1"><a class="class1" title="Docs.html" href="Docs.html">Docs</a> <span class="style">-&gt;</span> <span class="style_1">wolfSSL Manual</span></p>
</div>
</div>
</div>
<div style="height: 1px; width: 698px;  height: 1px; left: 37px; position: absolute; top: 220px; width: 698px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 698px; ">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_1.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 698px; "/>
</div>
</div>
<div style="height: 37px; width: 545px;  height: 37px; left: 191px; position: absolute; top: 80px; width: 545px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 545px; ">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_2.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 545px; "/>
</div>
</div>
<div id="id3" style="height: 25px; left: 200px; position: absolute; top: 84px; width: 43px; z-index: 1; " class="style_SkipStroke_1 shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_43_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_2"><a class="class2" title="Home.html" href="Home.html">Home</a></p>
</div>
</div>
</div>
<div id="id4" style="height: 25px; left: 365px; position: absolute; top: 84px; width: 72px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_72_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class3" title="https://wolfssl.com/wolfSSL/download/downloadForm.php" href="https://wolfssl.com/wolfSSL/download/downloadForm.php">Download</a></p>
</div>
</div>
</div>
<div id="id5" style="height: 25px; left: 439px; position: absolute; top: 84px; width: 59px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_59_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class4" title="License.html" href="License.html">License</a></p>
</div>
</div>
</div>
<div id="id6" style="height: 25px; left: 499px; position: absolute; top: 84px; width: 44px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_44_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class5" title="Blog/Blog.html" href="Blog/Blog.html">Blog</a></p>
</div>
</div>
</div>
<div id="id7" style="height: 25px; left: 589px; position: absolute; top: 84px; width: 80px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_80_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class6" title="Community.html" href="Community.html">Community</a></p>
</div>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 245px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_3.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 296px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_4.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 363px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_5.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 438px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_6.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 498px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_7.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 589px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_8.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id8" style="height: 25px; left: 671px; position: absolute; top: 84px; width: 61px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_61_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class7" title="Contact.html" href="Contact.html">Contact</a></p>
</div>
</div>
</div>
<div id="id9" style="height: 25px; left: 249px; position: absolute; top: 84px; width: 44px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_44_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_2"><a class="class8" title="About.html" href="About.html">About</a></p>
</div>
</div>
</div>
<div style="height: 36px; width: 1px;  height: 36px; left: 670px; position: absolute; top: 81px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_9.png" alt="" style="height: 36px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id10" style="height: 25px; left: 298px; position: absolute; top: 84px; width: 63px; z-index: 1; " class="style_SkipStroke_1 shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_63_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_3"><a class="class9" title="Products.html" href="Products.html">Products</a></p>
</div>
</div>
</div>
<div id="id11" style="height: 25px; left: 549px; position: absolute; top: 84px; width: 41px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_41_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_2"><a class="class10" title="Docs.html" href="Docs.html">Docs</a></p>
</div>
</div>
</div>
<div style="height: 37px; width: 1px;  height: 37px; left: 545px; position: absolute; top: 80px; width: 0px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 0px; ">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_10.png" alt="" style="height: 37px; left: 0px; position: absolute; top: 0px; width: 1px; "/>
</div>
</div>
<div id="id12" style="height: 27px; left: 634px; position: absolute; top: 224px; width: 102px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_102_27" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_4"><a class="class11" title="Docs-wolfssl-manual-18-4-wolfcrypt-api-blake2b.html" href="Docs-wolfssl-manual-18-4-wolfcrypt-api-blake2b.html">Next Chapter</a></p>
</div>
</div>
</div>
<div id="id13" style="height: 25px; left: 35px; position: absolute; top: 224px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_5"><a class="class12" title="Docs-wolfssl-manual-18-2-wolfcrypt-api-arc4.html" href="Docs-wolfssl-manual-18-2-wolfcrypt-api-arc4.html">Previous Chapter</a></p>
</div>
</div>
</div>
<div id="id14" style="height: 27px; left: 59px; position: absolute; top: 190px; width: 342px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_342_27" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_6"><a class="class13" title="https://www.wolfssl.com/documentation/wolfSSL-Manual.pdf" href="https://www.wolfssl.com/documentation/wolfSSL-Manual.pdf">Download wolfSSL Manual (PDF)</a></p>
</div>
</div>
</div>
<div style="height: 22px; width: 22px;  height: 22px; left: 33px; position: absolute; top: 191px; width: 22px; z-index: 1; " class="tinyText style_SkipStroke_2">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/PDF.png" alt="" style="border: none; height: 22px; width: 22px; "/>
</div>
<div id="id15" style="height: 25px; left: 323px; position: absolute; top: 224px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_7"><a title="Docs-wolfssl-manual-toc.html" href="Docs-wolfssl-manual-toc.html">Table of Contents</a></p>
</div>
</div>
</div>
<div id="id16" style="height: 12016px; left: 35px; position: absolute; top: 281px; width: 701px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_701_12016" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-top: 0pt; " class="paragraph_style_8">Chapter 18: wolfCrypt API Reference<br/></p>
<p class="paragraph_style_8"><br/></p>
<p class="paragraph_style_9">18.3  ASN<br/></p>
<p class="paragraph_style_9"><br/></p>
<p class="paragraph_style_10">The functions in this section expose ASN functionality to calling applications.<span class="style_2"><br/></span></p>
<p class="paragraph_style_11"><br/></p>
<p class="paragraph_style_11"><br/></p>
<div class="paragraph paragraph_style_11"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_11.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_11"><br/></p>
<p class="paragraph_style_12"><br/></p>
<p class="paragraph_style_13">wolfSSL_PemCertToDer<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wolfSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function converts a pem certificate to a der certificate, and places the resulting certificate in the derBuf buffer provided. <br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10">On success, returns the <span class="style_3">size</span> of the derBuf generated<br/></p>
<p class="paragraph_style_10"><span class="style_3">BUFFER_E</span>: Returned if the size of derBuf is too small to hold the certificate generated<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if the call to XMALLOC fails<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">fileName</span> - path to the file containing a pem certificate to convert to a der certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">derBuf</span> - pointer to a char buffer in which to store the converted certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">derSz</span> - size of the char buffer in which to store the converted certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">char * file = “./certs/client-cert.pem”;<br/></p>
<p class="paragraph_style_15">int derSz;<br/></p>
<p class="paragraph_style_15">byte * der = (byte*)XMALLOC(EIGHTK_BUF, NULL, DYNAMIC_TYPE_CERT);<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">derSz = wolfsSSL_PemCertToDer(file, der, EIGHTK_BUF);<br/></p>
<p class="paragraph_style_15">if(derSz &lt;= 0) {<br/></p>
<p class="paragraph_style_15">//PemCertToDer error<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_12.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">wc_InitCert<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">void wc_InitCert(Cert* cert)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function initializes a default cert, with the default options: <br/></p>
<p class="paragraph_style_10">    <span class="style_3">version</span> = 3 (0x2)<br/></p>
<p class="paragraph_style_10">    <span class="style_3">serial</span> = 0<br/></p>
<p class="paragraph_style_10">    <span class="style_3">sigType</span> = SHA_WITH_RSA<br/></p>
<p class="paragraph_style_10">    <span class="style_3">issuer</span> = blank<br/></p>
<p class="paragraph_style_10">    <span class="style_3">daysValid</span> = 500<br/></p>
<p class="paragraph_style_10">    <span class="style_3">selfSigned</span> = 1 (true) use subject as issuer<br/></p>
<p class="paragraph_style_10">    <span class="style_3">subject</span> = blank<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10">No return value for this function.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span> - pointer to an uninitialized cert structure to initialize<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">wc_InitCert(&amp;myCert);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_MakeCert, wc_MakeCertReq<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_13.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_MakeCert<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_MakeCert(Cert* cert, byte* derBuffer, word32 derSz, RsaKey* rsaKey,     <br/></p>
<p class="paragraph_style_10">    ecc_key* eccKey, RNG* rng);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">Used to make CA signed certs.  Called after the subject information has been entered. This function makes an x509 Certificate v3 RSA or ECC from a cert input. It then writes this cert to derBuffer. It takes in either an rsaKey or an eccKey to generate the certificate.  The certificate must be initialized with wc_InitCert before this method is called.  <br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10">On successfully making an x509 certificate from the specified input cert, returns the <span class="style_3">size</span> of the cert generated.<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">BUFFER_E</span>: Returned if the provided derBuffer is too small to store the generated certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_16">Others: <br/></p>
<p class="paragraph_style_10">Additional error messages may be returned if the cert generation is not successful.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span> - pointer to an initialized cert structure <br/></p>
<p class="paragraph_style_10"><span class="style_3">derBuffer</span> - pointer to the buffer in which to hold the generated cert<br/></p>
<p class="paragraph_style_10"><span class="style_3">derSz</span> - size of the buffer in which to store the cert<br/></p>
<p class="paragraph_style_10"><span class="style_3">rsaKey</span> - pointer to an RsaKey structure containing the rsa key used to generate the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">eccKey</span> - pointer to an EccKey structure containing the ecc key used to generate the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">rng</span> - pointer to the random number generator used to make the cert<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">wc_InitCert(&amp;myCert); <br/></p>
<p class="paragraph_style_15">RNG rng;<br/></p>
<p class="paragraph_style_15">//initialize rng;<br/></p>
<p class="paragraph_style_15">RsaKey key;<br/></p>
<p class="paragraph_style_15">//initialize key;<br/></p>
<p class="paragraph_style_15">byte * derCert = malloc(FOURK_BUF);<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">word32 certSz;<br/></p>
<p class="paragraph_style_15">certSz = wc_MakeCert(&amp;myCert, derCert, FOURK_BUF, &amp;key, NULL, &amp;rng);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert, wc_MakeCertReq<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_14.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_MakeCertReq<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_MakeCertReq(Cert* cert, byte* derBuffer, word32 derSz, RsaKey* rsaKey, <br/></p>
<p class="paragraph_style_10">ecc_key* eccKey)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function makes a certificate signing request using the input certificate and writes the output to derBuffer. It takes in either an rsaKey or an eccKey to generate the certificate request.  wc_SignCert() will need to be called after this function to sign the certificate request.  Please see the wolfCrypt test application (./wolfcrypt/test/test.c) for an example usage of this function.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10">On successfully making an x509 certificate request from the specified input cert, returns the size of the certificate request generated.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">BUFFER_E</span>: Returned if the provided derBuffer is too small to store the generated certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">Others</span>: <br/></p>
<p class="paragraph_style_10">Additional error messages may be returned if the certificate request generation is not successful.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span> - pointer to an initialized cert structure <br/></p>
<p class="paragraph_style_10"><span class="style_3">derBuffer</span> - pointer to the buffer in which to hold the generated certificate request<br/></p>
<p class="paragraph_style_10"><span class="style_3">derSz</span> - size of the buffer in which to store the certificate request<br/></p>
<p class="paragraph_style_10"><span class="style_3">rsaKey</span> - pointer to an RsaKey structure containing the rsa key used to generate the certificate request<br/></p>
<p class="paragraph_style_10"><span class="style_3">eccKey</span> - pointer to an EccKey structure containing the ecc key used to generate the certificate request<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">// initialize myCert<br/></p>
<p class="paragraph_style_15">EccKey key;<br/></p>
<p class="paragraph_style_15">//initialize key;<br/></p>
<p class="paragraph_style_15">byte* derCert = (byte*)malloc(FOURK_BUF);<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">word32 certSz;<br/></p>
<p class="paragraph_style_15">certSz = wc_MakeCertReq(&amp;myCert, derCert, FOURK_BUF, NULL, &amp;key);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert, wc_MakeCert<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_15.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_SignCert<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_SignCert(int requestSz, int sType, byte* buffer, word32 buffSz,<br/></p>
<p class="paragraph_style_10">         RsaKey* rsaKey, ecc_key* eccKey, RNG* rng)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function signs <span class="style_3">buffer</span> and adds the signature to the end of <span class="style_3">buffer</span>. It takes in a signature type.  Must be called after wc_MakeCert() or wc_MakeCertReq() if creating a CA signed cert.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10">On successfully signing the certificate, returns the new <span class="style_3">size</span> of the cert (including signature).<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">BUFFER_E</span>: Returned if the provided buffer is too small to store the generated certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">Others</span>: <br/></p>
<p class="paragraph_style_10">Additional error messages may be returned if the cert generation is not successful.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">requestSz</span>  - the size of the certificate body we’re requesting to have signed<br/></p>
<p class="paragraph_style_10"><span class="style_3">sType</span> - Type of signature to create. Valid options are: CTC_MD5wRSA, CTC_SHAwRSA, CTC_SHAwECDSA, CTC_SHA256wECDSA, andCTC_SHA256wRSA<br/></p>
<p class="paragraph_style_10"><span class="style_3">buffer</span> - pointer to the buffer containing the certificate to be signed.  On success: will hold the newly signed certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">buffSz</span> - the (total) size of the buffer in which to store the newly signed certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">rsaKey</span> - pointer to an RsaKey structure containing the rsa key to used to sign the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">eccKey</span> - pointer to an EccKey structure containing the ecc key to used to sign the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">rng</span> - pointer to the random number generator used to sign the certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">byte* derCert = (byte*)malloc(FOURK_BUF);<br/></p>
<p class="paragraph_style_15">// initialize myCert, derCert<br/></p>
<p class="paragraph_style_15">RsaKey key;<br/></p>
<p class="paragraph_style_15">// initialize key;<br/></p>
<p class="paragraph_style_15">RNG rng;<br/></p>
<p class="paragraph_style_15">// initialize rng<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">word32 certSz;<br/></p>
<p class="paragraph_style_15">certSz = wc_SignCert(myCert.bodySz, myCert.sigType,derCert,FOURK_BUF, &amp;key, NULL, <br/></p>
<p class="paragraph_style_15">&amp;rng);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert, wc_MakeCert<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_16.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_MakeSelfCert<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_MakeSelfCert(Cert* cert, byte* buffer, word32 buffSz, RsaKey* key, RNG* rng)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function is a combination of the previous two functions, wc_MakeCert and wc_SignCert for self signing (the previous functions may be used for CA requests). It makes a certificate, and then signs it, generating a self-signed certificate.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10">On successfully signing the certificate, returns the new <span class="style_3">size</span> of the cert.<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">BUFFER_E</span>: Returned if the provided buffer is too small to store the generated certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">Others</span>: <br/></p>
<p class="paragraph_style_10">Additional error messages may be returned if the cert generation is not successful.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span>  - pointer to the cert to make and sign<br/></p>
<p class="paragraph_style_10"><span class="style_3">buffer</span> - pointer to the buffer in which to hold the signed certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">buffSz</span> - size of the buffer in which to store the signed certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">key</span> - pointer to an RsaKey structure containing the rsa key to used to sign the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">rng</span> - pointer to the random number generator used to generate and sign the certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">byte* derCert = (byte*)malloc(FOURK_BUF);<br/></p>
<p class="paragraph_style_15">// initialize myCert, derCert<br/></p>
<p class="paragraph_style_15">RsaKey key;<br/></p>
<p class="paragraph_style_15">// initialize key;<br/></p>
<p class="paragraph_style_15">RNG rng;<br/></p>
<p class="paragraph_style_15">// initialize rng<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">word32 certSz;<br/></p>
<p class="paragraph_style_15">certSz = wc_MakeSelfCert(&amp;myCert, derCert, FOURK_BUF, &amp;key, NULL, &amp;rng);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert, wc_MakeCert, wc_SignCert<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_17.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_SetIssuer<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_SetIssuer(Cert* cert, const char* issuerFile)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function sets the issuer for a certificate to the issuer in the provided pem issuerFile. It also changes the certificate’s self-signed attribute to false.  The issuer specified in issuerFile is verified prior to setting the cert issuer.  This method is used to set fields prior to signing.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span>: Returned on successfully setting the issuer for the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_PARSE_E</span>: Returned if there is an error parsing the cert header file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_OBJECT_ID_E</span>: Returned if there is an error parsing the encryption type from the cert<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_EXPECT_0_E</span>: Returned if there is a formatting error in the encryption specification of the cert file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BEFORE_DATE_E</span>: Returned if the date is before the certificate start date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_AFTER_DATE_E</span>: Returned if the date is after the certificate expiration date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BITSTR_E</span>: Returned if there is an error parsing a bit string from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NTRU_KEY_E</span>: Returned if there is an error parsing the NTRU key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ECC_CURVE_OID_E</span>: Returned if there is an error parsing the ECC key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_UNKNOWN_OID_E</span>: Returned if the certificate is using an unknown key object id<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_VERSION_E</span>: Returned if the ALLOW_V1_EXTENSIONS option is not defined and the certificate is a V1 or V2 certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">BAD_FUNC_ARG</span>: Returned if there is an error processing the certificate extension<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_CRIT_EXT_E</span>: Returned if an unfamiliar critical extension is encountered in processing the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_OID_E</span>: Returned if the signature encryption type is not the same as the encryption type of the certificate in the provided file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_CONFIRM_E</span>: Returned if confirming the certification signature fails<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NAME_INVALID_E</span>: Returned if the certificate’s name is not permitted by the CA name constraints<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NO_SIGNER_E</span>: Returned if there is no CA signer to verify the certificate’s authenticity<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span>  - pointer to the cert for which to set the issuer<br/></p>
<p class="paragraph_style_10"><span class="style_3">issuerFile</span> - path of the file containing the pem formatted certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">// initialize myCert<br/></p>
<p class="paragraph_style_15">if(wc_SetIssuer(&amp;myCert, ”./path/to/ca-cert.pem”) != 0) {<br/></p>
<p class="paragraph_style_15">// error setting issuer<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert, wc_SetSubject, wc_SetIssuerBuffer<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_18.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_SetSubject<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_SetSubject(Cert* cert, const char* subjectFile)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function sets the subject for a certificate to the subject in the provided pem subjectFile.  This method is used to set fields prior to signing.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span>: Returned on successfully setting the issuer for the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_PARSE_E</span>: Returned if there is an error parsing the cert header file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_OBJECT_ID_E</span>: Returned if there is an error parsing the encryption type from the cert<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_EXPECT_0_E</span>: Returned if there is a formatting error in the encryption specification of the cert file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BEFORE_DATE_E</span>: Returned if the date is before the certificate start date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_AFTER_DATE_E</span>: Returned if the date is after the certificate expiration date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BITSTR_E</span>: Returned if there is an error parsing a bit string from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NTRU_KEY_E</span>: Returned if there is an error parsing the NTRU key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ECC_CURVE_OID_E</span>: Returned if there is an error parsing the ECC key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_UNKNOWN_OID_E</span>: Returned if the certificate is using an unknown key object id<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_VERSION_E</span>: Returned if the ALLOW_V1_EXTENSIONS option is not defined and the certificate is a V1 or V2 certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">BAD_FUNC_ARG</span>: Returned if there is an error processing the certificate extension<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_CRIT_EXT_E</span>: Returned if an unfamiliar critical extension is encountered in processing the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_OID_E</span>: Returned if the signature encryption type is not the same as the encryption type of the certificate in the provided file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_CONFIRM_E</span>: Returned if confirming the certification signature fails<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NAME_INVALID_E</span>: Returned if the certificate’s name is not permitted by the CA name constraints<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NO_SIGNER_E</span>: Returned if there is no CA signer to verify the certificate’s authenticity<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span>  - pointer to the cert for which to set the issuer<br/></p>
<p class="paragraph_style_10"><span class="style_3">subjectFile</span> - path of the file containing the pem formatted certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">// initialize myCert<br/></p>
<p class="paragraph_style_15">if(wc_SetSubject(&amp;myCert, ”./path/to/ca-cert.pem”) != 0) {<br/></p>
<p class="paragraph_style_15">// error setting subject<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert, wc_SetIssuer<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_19.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_SetAltNames<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_SetAltNames(Cert* cert, const char* file)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function sets the alternate names for a certificate to the alternate names in the provided pem file. This is useful in the case that one wishes to secure multiple domains with the same certificate. This method is used to set fields prior to signing.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span>: Returned on successfully setting the alt names for the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_PARSE_E</span>: Returned if there is an error parsing the cert header file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_OBJECT_ID_E</span>: Returned if there is an error parsing the encryption type from the cert<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_EXPECT_0_E</span>: Returned if there is a formatting error in the encryption specification of the cert file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BEFORE_DATE_E</span>: Returned if the date is before the certificate start date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_AFTER_DATE_E</span>: Returned if the date is after the certificate expiration date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BITSTR_E</span>: Returned if there is an error parsing a bit string from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NTRU_KEY_E</span>: Returned if there is an error parsing the NTRU key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ECC_CURVE_OID_E</span>: Returned if there is an error parsing the ECC key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_UNKNOWN_OID_E</span>: Returned if the certificate is using an unknown key object id<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_VERSION_E</span>: Returned if the ALLOW_V1_EXTENSIONS option is not defined and the certificate is a V1 or V2 certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">BAD_FUNC_ARG</span>: Returned if there is an error processing the certificate extension<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_CRIT_EXT_E</span>: Returned if an unfamiliar critical extension is encountered in processing the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_OID_E</span>: Returned if the signature encryption type is not the same as the encryption type of the certificate in the provided file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_CONFIRM_E</span>: Returned if confirming the certification signature fails<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NAME_INVALID_E</span>: Returned if the certificate’s name is not permitted by the CA name constraints<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NO_SIGNER_E</span>: Returned if there is no CA signer to verify the certificate’s authenticity<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span>  - pointer to the cert for which to set the alt names<br/></p>
<p class="paragraph_style_10"><span class="style_3">file</span> - path of the file containing the pem formatted certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">// initialize myCert<br/></p>
<p class="paragraph_style_15">if(wc_SetSubject(&amp;myCert, ”./path/to/ca-cert.pem”) != 0) {<br/></p>
<p class="paragraph_style_15">// error setting alt names<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert, wc_SetIssuer<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_20.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_SetIssuerBuffer<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_SetIssuerBuffer(Cert* cert, const byte* der, int derSz);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function sets the issuer for a certificate from the issuer in the provided der buffer. It also changes the certificate’s self-signed attribute to false.  This method is used to set fields prior to signing.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span>: Returned on successfully setting the issuer for the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_PARSE_E</span>: Returned if there is an error parsing the cert header file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_OBJECT_ID_E</span>: Returned if there is an error parsing the encryption type from the cert<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_EXPECT_0_E</span>: Returned if there is a formatting error in the encryption specification of the cert file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BEFORE_DATE_E</span>: Returned if the date is before the certificate start date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_AFTER_DATE_E</span>: Returned if the date is after the certificate expiration date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BITSTR_E</span>: Returned if there is an error parsing a bit string from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NTRU_KEY_E</span>: Returned if there is an error parsing the NTRU key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ECC_CURVE_OID_E</span>: Returned if there is an error parsing the ECC key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_UNKNOWN_OID_E</span>: Returned if the certificate is using an unknown key object id<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_VERSION_E</span>: Returned if the ALLOW_V1_EXTENSIONS option is not defined and the certificate is a V1 or V2 certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">BAD_FUNC_ARG</span>: Returned if there is an error processing the certificate extension<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_CRIT_EXT_E</span>: Returned if an unfamiliar critical extension is encountered in processing the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_OID_E</span>: Returned if the signature encryption type is not the same as the encryption type of the certificate in the provided file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_CONFIRM_E</span>: Returned if confirming the certification signature fails<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NAME_INVALID_E</span>: Returned if the certificate’s name is not permitted by the CA name constraints<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NO_SIGNER_E</span>: Returned if there is no CA signer to verify the certificate’s authenticity<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span>  - pointer to the cert for which to set the issuer<br/></p>
<p class="paragraph_style_10"><span class="style_3">der</span> - pointer to the buffer containing the der formatted certificate from which to grab the issuer<br/></p>
<p class="paragraph_style_10"><span class="style_3">derSz</span> - size of the buffer containing the der formatted certificate from which to grab the issuer<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">// initialize myCert<br/></p>
<p class="paragraph_style_15">byte* der;<br/></p>
<p class="paragraph_style_15">der = (byte*)malloc(FOURK_BUF);<br/></p>
<p class="paragraph_style_15">// initialize der<br/></p>
<p class="paragraph_style_15">if(wc_SetIssuerBuffer(&amp;myCert, der, FOURK_BUF) != 0) {<br/></p>
<p class="paragraph_style_15">// error setting issuer<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert, wc_SetIssuer<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_21.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_SetSubjectBuffer<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_SetSubjectBuffer(Cert* cert, const byte* der, int derSz);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function sets the subject for a certificate from the subject in the provided der buffer.  This method is used to set fields prior to signing.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span>: Returned on successfully setting the subject for the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_PARSE_E</span>: Returned if there is an error parsing the cert header file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_OBJECT_ID_E</span>: Returned if there is an error parsing the encryption type from the cert<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_EXPECT_0_E</span>: Returned if there is a formatting error in the encryption specification of the cert file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BEFORE_DATE_E</span>: Returned if the date is before the certificate start date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_AFTER_DATE_E</span>: Returned if the date is after the certificate expiration date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BITSTR_E</span>: Returned if there is an error parsing a bit string from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NTRU_KEY_E</span>: Returned if there is an error parsing the NTRU key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ECC_CURVE_OID_E</span>: Returned if there is an error parsing the ECC key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_UNKNOWN_OID_E</span>: Returned if the certificate is using an unknown key object id<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_VERSION_E</span>: Returned if the ALLOW_V1_EXTENSIONS option is not defined and the certificate is a V1 or V2 certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">BAD_FUNC_ARG</span>: Returned if there is an error processing the certificate extension<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_CRIT_EXT_E</span>: Returned if an unfamiliar critical extension is encountered in processing the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_OID_E</span>: Returned if the signature encryption type is not the same as the encryption type of the certificate in the provided file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_CONFIRM_E</span>: Returned if confirming the certification signature fails<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NAME_INVALID_E</span>: Returned if the certificate’s name is not permitted by the CA name constraints<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NO_SIGNER_E</span>: Returned if there is no CA signer to verify the certificate’s authenticity<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span>  - pointer to the cert for which to set the subject<br/></p>
<p class="paragraph_style_10"><span class="style_3">der</span> - pointer to the buffer containing the der formatted certificate from which to grab the subject<br/></p>
<p class="paragraph_style_10"><span class="style_3">derSz</span> - size of the buffer containing the der formatted certificate from which to grab the subject<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">// initialize myCert<br/></p>
<p class="paragraph_style_15">byte* der;<br/></p>
<p class="paragraph_style_15">der = (byte*)malloc(FOURK_BUF);<br/></p>
<p class="paragraph_style_15">// initialize der<br/></p>
<p class="paragraph_style_15">if(wc_SetSubjectBuffer(&amp;myCert, der, FOURK_BUF) != 0) {<br/></p>
<p class="paragraph_style_15">// error setting subject<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert, wc_SetSubject<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_22.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_SetAltNamesBuffer<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_SetAltNamesBuffer(Cert* cert, const byte* der, int derSz)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function sets the alternate names for a certificate from the alternate names in the provided der buffer. This is useful in the case that one wishes to secure multiple domains with the same certificate.  This method is used to set fields prior to signing.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span>: Returned on successfully setting the alternate names for the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_PARSE_E</span>: Returned if there is an error parsing the cert header file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_OBJECT_ID_E</span>: Returned if there is an error parsing the encryption type from the cert<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_EXPECT_0_E</span>: Returned if there is a formatting error in the encryption specification of the cert file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BEFORE_DATE_E</span>: Returned if the date is before the certificate start date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_AFTER_DATE_E</span>: Returned if the date is after the certificate expiration date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BITSTR_E</span>: Returned if there is an error parsing a bit string from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NTRU_KEY_E</span>: Returned if there is an error parsing the NTRU key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ECC_CURVE_OID_E</span>: Returned if there is an error parsing the ECC key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_UNKNOWN_OID_E</span>: Returned if the certificate is using an unknown key object id<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_VERSION_E</span>: Returned if the ALLOW_V1_EXTENSIONS option is not defined and the certificate is a V1 or V2 certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">BAD_FUNC_ARG</span>: Returned if there is an error processing the certificate extension<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_CRIT_EXT_E</span>: Returned if an unfamiliar critical extension is encountered in processing the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_OID_E</span>: Returned if the signature encryption type is not the same as the encryption type of the certificate in the provided file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_CONFIRM_E</span>: Returned if confirming the certification signature fails<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NAME_INVALID_E</span>: Returned if the certificate’s name is not permitted by the CA name constraints<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NO_SIGNER_E</span>: Returned if there is no CA signer to verify the certificate’s authenticity<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span>  - pointer to the cert for which to set the alternate names<br/></p>
<p class="paragraph_style_10"><span class="style_3">der</span> - pointer to the buffer containing the der formatted certificate from which to grab the alternate names<br/></p>
<p class="paragraph_style_10"><span class="style_3">derSz</span> - size of the buffer containing the der formatted certificate from which to grab the alternate names<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">// initialize myCert<br/></p>
<p class="paragraph_style_15">byte* der;<br/></p>
<p class="paragraph_style_15">der = (byte*)malloc(FOURK_BUF);<br/></p>
<p class="paragraph_style_15">// initialize der<br/></p>
<p class="paragraph_style_15">if(wc_SetAltNamesBuffer(&amp;myCert, der, FOURK_BUF) != 0) {<br/></p>
<p class="paragraph_style_15">// error setting subject<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert, wc_SetAltNames<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_23.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_SetDatesBuffer<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_SetDatesBuffer(Cert* cert, const byte* der, int derSz)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function sets the dates for a certificate from the date range in the provided der buffer. This method is used to set fields prior to signing.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span>: Returned on successfully setting the dates for the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_PARSE_E</span>: Returned if there is an error parsing the cert header file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_OBJECT_ID_E</span>: Returned if there is an error parsing the encryption type from the cert<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_EXPECT_0_E</span>: Returned if there is a formatting error in the encryption specification of the cert file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BEFORE_DATE_E</span>: Returned if the date is before the certificate start date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_AFTER_DATE_E</span>: Returned if the date is after the certificate expiration date<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_BITSTR_E</span>: Returned if there is an error parsing a bit string from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NTRU_KEY_E</span>: Returned if there is an error parsing the NTRU key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ECC_CURVE_OID_E</span>: Returned if there is an error parsing the ECC key from the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_UNKNOWN_OID_E</span>: Returned if the certificate is using an unknown key object id<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_VERSION_E</span>: Returned if the ALLOW_V1_EXTENSIONS option is not defined and the certificate is a V1 or V2 certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">BAD_FUNC_ARG</span>: Returned if there is an error processing the certificate extension<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_CRIT_EXT_E</span>: Returned if an unfamiliar critical extension is encountered in processing the certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_OID_E</span>: Returned if the signature encryption type is not the same as the encryption type of the certificate in the provided file<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_SIG_CONFIRM_E</span>: Returned if confirming the certification signature fails<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NAME_INVALID_E</span>: Returned if the certificate’s name is not permitted by the CA name constraints<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_NO_SIGNER_E</span>: Returned if there is no CA signer to verify the certificate’s authenticity<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span>  - pointer to the cert for which to set the dates<br/></p>
<p class="paragraph_style_10"><span class="style_3">der</span> - pointer to the buffer containing the der formatted certificate from which to grab the date range<br/></p>
<p class="paragraph_style_10"><span class="style_3">derSz</span> - size of the buffer containing the der formatted certificate from which to grab the date range<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">// initialize myCert<br/></p>
<p class="paragraph_style_15">byte* der;<br/></p>
<p class="paragraph_style_15">der = (byte*)malloc(FOURK_BUF);<br/></p>
<p class="paragraph_style_15">// initialize der<br/></p>
<p class="paragraph_style_15">if(wc_SetDatesBuffer(&amp;myCert, der, FOURK_BUF) != 0) {<br/></p>
<p class="paragraph_style_15">// error setting subject<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_24.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_MakeNtruCert<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_MakeNtruCert(Cert* cert, byte* derBuffer, word32 derSz, const byte* ntruKey, <br/></p>
<p class="paragraph_style_10">                                    word16 keySz, RNG* rng)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">Used to make CA signed certs.  Called after the subject information has been entered. This function makes an NTRU Certificate from a cert input. It then writes this cert to derBuffer. It takes in an ntruKey and a rng to generate the certificate.  The certificate must be initialized with wc_InitCert before this method is called.  <br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10">On successfully making a NTRU certificate from the specified input cert, returns the <span class="style_3">size</span> of the cert generated.<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">BUFFER_E</span>: Returned if the provided derBuffer is too small to store the generated certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10"><span class="style_3">Others</span>: <br/></p>
<p class="paragraph_style_10">Additional error messages may be returned if the cert generation is not successful.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">cert</span>  - pointer to an initialized cert structure<br/></p>
<p class="paragraph_style_10"><span class="style_3">derBuffer</span> - pointer to the buffer in which to store the generated certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">derSz</span> - size of the buffer in which to store the generated  certificate <br/></p>
<p class="paragraph_style_10"><span class="style_3">ntruKey</span> - pointer to the key to be used to generate the NTRU certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">keySz</span> - size of the key used to generate the NTRU certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">rng</span> - pointer to the random number generator used to generate the NTRU certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">Cert myCert;<br/></p>
<p class="paragraph_style_15">// initialize myCert<br/></p>
<p class="paragraph_style_15">RNG rng;<br/></p>
<p class="paragraph_style_15">//initialize rng;<br/></p>
<p class="paragraph_style_15">byte ntruPublicKey[NTRU_KEY_SIZE];<br/></p>
<p class="paragraph_style_15">//initialize ntruPublicKey;<br/></p>
<p class="paragraph_style_15">byte * derCert = malloc(FOURK_BUF);<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">word32 certSz;<br/></p>
<p class="paragraph_style_15">certSz = wc_MakeNtruCert(&amp;myCert, derCert, FOURK_BUF, &amp;ntruPublicKey, NTRU_KEY_SIZE, &amp;rng);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_InitCert, wc_MakeCert<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_25.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13">wc_DerToPem<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_DerToPem(const byte* der, word32 derSz, byte* output, word32 outSz, int type)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function converts a der formatted input certificate, contained in the der buffer, into a pem formatted output certificate, contained in the output buffer. It should be noted that this is not an in place conversion, and a separate buffer must be utilized to store the pem formatted output. <br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10">On successfully making a pem certificate from the input der cert, returns the <span class="style_3">size</span> of the pem cert generated.<br/></p>
<p class="paragraph_style_10"><span class="style_3">BAD_FUNC_ARG</span>: Returned if there is an error parsing the der file and storing it as a pem file<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_INPUT_E</span>: Returned in the case of a base 64 encoding error<br/></p>
<p class="paragraph_style_10"><span class="style_3">BUFFER_E</span>: May be returned if the output buffer is too small to store the pem formatted certificate<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">der</span> - pointer to the buffer of the certificate to convert<br/></p>
<p class="paragraph_style_10"><span class="style_3">derSz</span> - size of the the certificate to convert <br/></p>
<p class="paragraph_style_10"><span class="style_3">output</span> - pointer to the buffer in which to store the pem formatted certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">outSz</span> - size of the buffer in which to store the pem formatted certificate<br/></p>
<p class="paragraph_style_10"><span class="style_3">type</span> - the type of certificate to generate. Valid types are: CERT_TYPE, PRIVATEKEY_TYPE, ECC_PRIVATEKEY_TYPE, and CERTREQ_TYPE. <br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">byte* der;<br/></p>
<p class="paragraph_style_15">// initialize der with certificate<br/></p>
<p class="paragraph_style_15">byte* pemFormatted[FOURK_BUF];<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">word32 pemSz;<br/></p>
<p class="paragraph_style_15">pemSz = wc_DerToPem(der, derSz,pemFormatted,FOURK_BUF, CERT_TYPE);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wolfSSL_PemCertToDer<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_26.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_EccPrivateKeyDecode<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key,<br/></p>
<p class="paragraph_style_10">                    word32 inSz);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function reads in an ECC private key from the input buffer, input, parses the private key, and uses it to generate an ecc_key object, which it stores in key. <br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span>: On successfully decoding the private key and storing the result in the ecc_key struct<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_PARSE_E</span>: Returned if there is an error parsing the der file and storing it as a pem file<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">BUFFER_E</span>: Returned if the certificate to convert is large than the specified max certificate size<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_OBJECT_ID_E</span>: Returned if the certificate encoding has an invalid object id<br/></p>
<p class="paragraph_style_10"><span class="style_3">ECC_CURVE_OID_E</span>: Returned if the ECC curve of the provided key is not supported<br/></p>
<p class="paragraph_style_10"><span class="style_3">ECC_BAD_ARG_E</span>: Returned if there is an error in the ECC key format<br/></p>
<p class="paragraph_style_10"><span class="style_3">NOT_COMPILED_IN</span>: Returned if the private key is compressed, and no compression key is provided<br/></p>
<p class="paragraph_style_10"><span class="style_3">MP_MEM</span>: Returned if there is an error in the math library used while parsing the private key <br/></p>
<p class="paragraph_style_10"><span class="style_3">MP_VAL</span>: Returned if there is an error in the math library used while parsing the private key <br/></p>
<p class="paragraph_style_10"><span class="style_3">MP_RANGE</span>: Returned if there is an error in the math library used while parsing the private key<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">input</span> - pointer to the buffer containing the input private key<br/></p>
<p class="paragraph_style_10"><span class="style_3">inOutIdx</span> - pointer to a word32 object containing the index in the buffer at which to start<br/></p>
<p class="paragraph_style_10"><span class="style_3">key</span> - pointer to an initialized ecc object, on which to store the decoded private key<br/></p>
<p class="paragraph_style_10"><span class="style_3">inSz</span> - size of the input buffer containing the private key<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">int ret, idx=0;<br/></p>
<p class="paragraph_style_15">ecc_key key; // to store key in <br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">byte* tmp; // tmp buffer to read key from<br/></p>
<p class="paragraph_style_15">tmp = (byte*) malloc(FOURK_BUF);<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">int inSz;<br/></p>
<p class="paragraph_style_15">inSz = fread(tmp, 1, FOURK_BUF, privateKeyFile); <br/></p>
<p class="paragraph_style_15">// read key into tmp buffer<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">wc_ecc_init(&amp;key); // initialize key<br/></p>
<p class="paragraph_style_15">ret = wc_Ecc_PrivateKeyDecode(tmp, &amp;idx, &amp;key, (word32)inSz);<br/></p>
<p class="paragraph_style_15">if(ret &lt; 0) {<br/></p>
<p class="paragraph_style_15">// error decoding ecc key<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_RSA_PrivateKeyDecode<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_27.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_EccKeyToDer<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_EccKeyToDer(ecc_key* key, byte* output, word32 inLen);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function writes a private ECC key to der format. <br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10">On successfully writing the ECC key to der format, returns the <span class="style_3">length</span> written to the buffer<br/></p>
<p class="paragraph_style_10"><span class="style_3">BAD_FUNC_ARG</span>: Returned if key or output is null, or inLen equals zero<br/></p>
<p class="paragraph_style_10"><span class="style_3">MEMORY_E</span>: Returned if there is an error allocating memory with XMALLOC<br/></p>
<p class="paragraph_style_10"><span class="style_3">BUFFER_E</span>: Returned if the converted certificate is too large to store in the output buffer<br/></p>
<p class="paragraph_style_10"><span class="style_3">ASN_UNKNOWN_OID_E</span>: Returned if the ECC key used is of an unknown type<br/></p>
<p class="paragraph_style_10"><span class="style_3">MP_MEM</span>: Returned if there is an error in the math library used while parsing the private key <br/></p>
<p class="paragraph_style_10"><span class="style_3">MP_VAL</span>: Returned if there is an error in the math library used while parsing the private key <br/></p>
<p class="paragraph_style_10"><span class="style_3">MP_RANGE</span>: Returned if there is an error in the math library used while parsing the private key<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">key</span> - pointer to the buffer containing the input ecc key<br/></p>
<p class="paragraph_style_10"><span class="style_3">output</span> - pointer to a buffer in which to store the der formatted key<br/></p>
<p class="paragraph_style_10"><span class="style_3">inLen</span> - the length of the buffer in which to store the der formatted key<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">int derSz;<br/></p>
<p class="paragraph_style_15">ecc_key key;<br/></p>
<p class="paragraph_style_15">// initialize and make key<br/></p>
<p class="paragraph_style_15">byte der[FOURK_BUF];<br/></p>
<p class="paragraph_style_15">// store der formatted key here<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">derSz = wc_EccKeyToDer(&amp;key, der, FOURK_BUF);<br/></p>
<p class="paragraph_style_15">if(derSz &lt; 0) {<br/></p>
<p class="paragraph_style_15">// error converting ecc key to der buffer<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">See Also:<br/></p>
<p class="paragraph_style_10">wc_RsaKeyToDer<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_28.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_EncodeSignature<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">word32 wc_EncodeSignature(byte* out, const byte* digest, word32 digSz, int hashOID)<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function encodes a digital signature into the output buffer, and returns the size of the encoded signature created. <br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10">On successfully writing the encoded signature to output, returns the length written to the buffer<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">out</span> - pointer to the buffer where the encoded signature will be written<br/></p>
<p class="paragraph_style_10"><span class="style_3">digest</span> - pointer to the digest to use to encode the signature<br/></p>
<p class="paragraph_style_10"><span class="style_3">digSz</span> - the length of the buffer containing the digest<br/></p>
<p class="paragraph_style_10"><span class="style_3">hashOID</span> - OID identifying the hash type used to generate the signature. Valid options, depending on build configurations, are: SHAh, SHA256h, SHA384h, SHA512h, MD2h, MD5h, DESb, DES3b, CTC_MD5wRSA, CTC_SHAwRSA, CTC_SHA256wRSA, CTC_SHA384wRSA, CTC_SHA512wRSA, CTC_SHAwECDSA, CTC_SHA256wECDSA, CTC_SHA384wECDSA, and CTC_SHA512wECDSA. <br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">int signSz;<br/></p>
<p class="paragraph_style_15">byte encodedSig[MAX_ENCODED_SIG_SZ];<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">Sha256 sha256;<br/></p>
<p class="paragraph_style_15">// initialize sha256 for hashing<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">byte* dig = = (byte*)malloc(SHA256_DIGEST_SIZE);<br/></p>
<p class="paragraph_style_15">/* perform hashing and hash updating so dig stores SHA-256 hash<br/></p>
<p class="paragraph_style_15">(see wc_InitSha256, wc_Sha256Update and wc_Sha256Final)*/<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">signSz = wc_EncodeSignature(encodedSig, dig, SHA256_DIGEST_SIZE,SHA256h);<br/></p>
<p class="paragraph_style_10"><br/></p>
<div class="paragraph paragraph_style_10"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_29.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_13"><br/></p>
<p class="paragraph_style_13">wc_GetCTC_HashOID<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Synopsis:<br/></p>
<p class="paragraph_style_10">#include &lt;wolfssl/wolfcrypt/asn_public.h&gt;<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_10">int wc_GetCTC_HashOID(int type);<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Description:<br/></p>
<p class="paragraph_style_10">This function returns the hash OID that corresponds to a hashing type. For example, when given the type: SHA512, this function returns the identifier corresponding to a SHA512 hash, SHA512h. <br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Return Values:<br/></p>
<p class="paragraph_style_10">On success, returns the <span class="style_3">OID</span> corresponding to the appropriate hash to use with that encryption type.<br/></p>
<p class="paragraph_style_10"><span class="style_3">0</span>: Returned if an unrecognized hash type is passed in as argument.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Parameters:<br/></p>
<p class="paragraph_style_10"><span class="style_3">type</span> - the hash type for which to find the OID. Valid options, depending on build configuration, include: MD2, MD5, SHA, SHA256, SHA512, SHA384, and SHA512.<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_14">Example:<br/></p>
<p class="paragraph_style_15">int hashOID;<br/></p>
<p class="paragraph_style_15"><br/></p>
<p class="paragraph_style_15">hashOID = wc_GetCTC_HashOID(SHA512);<br/></p>
<p class="paragraph_style_15">if (hashOID == 0) {<br/></p>
<p class="paragraph_style_15">// WOLFSSL_SHA512 not defined<br/></p>
<p class="paragraph_style_15">}<br/></p>
<p class="paragraph_style_10"><br/></p>
<p class="paragraph_style_11"><br/></p>
<div class="paragraph paragraph_style_11"><div style="height: 1px; width: 693px;  height: 1px; left: 0px; position: relative; top: 1px; width: 693px; " class="tinyText inline-block"><div style="position: relative; width: 693px; "><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_30.jpg" alt="" style="height: 1px; left: 0px; position: absolute; top: 0px; width: 693px; "/></div></div><br/></div>
</div>
<div style="clear: both; height: 0px; line-height: 0px; " class="tinyText"> </div>
</div>
</div>
<div style="height: 16px; width: 20px;  height: 16px; left: 706px; position: absolute; top: 51px; width: 20px; z-index: 1; " class="tinyText">
<div style="position: relative; width: 20px; ">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/shapeimage_31.png" alt="" style="height: 16px; left: 0px; position: absolute; top: 0px; width: 20px; "/>
</div>
</div>
<div style="height: 19px; width: 19px;  height: 19px; left: 707px; position: absolute; top: 25px; width: 19px; z-index: 1; " class="tinyText style_SkipStroke_2">
<img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/United%20Kingdom(Great%20Britain).png" alt="" style="border: none; height: 19px; width: 19px; "/>
</div>
<div id="id17" style="height: 23px; left: 328px; position: absolute; top: 48px; width: 258px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_258_23" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_17">Questions? +1 (425) 245-8247</p>
</div>
</div>
</div>
<div style="height: 19px; width: 19px;  height: 19px; left: 685px; position: absolute; top: 25px; width: 19px; z-index: 1; " class="tinyText style_SkipStroke_2">
<a href="http://www.wolfssl.jp/" title="http://www.wolfssl.jp"><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/japan.png" alt="" style="border: none; height: 19px; width: 19px; "/></a>
</div>
<div id="id18" style="height: 28px; left: 593px; position: absolute; top: 44px; width: 119px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_119_28" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_18"><a class="class14" title="https://www.wolfssl.com/forums" href="https://www.wolfssl.com/forums">Support <span class="style_4">Forums</span></a></p>
</div>
</div>
</div>
<div style="height: 121px; width: 155px;  height: 121px; left: 32px; position: absolute; top: 5px; width: 155px; z-index: 1; " class="tinyText style_SkipStroke_2">
<a href="Home.html" title="Home.html"><img src="Docs-wolfssl-manual-18-3-wolfcrypt-api-asn_files/wolfssl_logo.png" alt="" style="border: none; height: 121px; width: 156px; "/></a>
</div>
<div style="height: 12297px; line-height: 12297px; " class="spacer"> </div>
</div>
<div style="height: 100px; margin-left: 0px; position: relative; width: 770px; z-index: 15; " id="footer_layer">
<div style="height: 0px; line-height: 0px; " class="bumper"> </div>
<div id="id19" style="height: 27px; left: 634px; position: absolute; top: 27px; width: 102px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_102_27" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_4"><a class="class15" title="Docs-wolfssl-manual-18-4-wolfcrypt-api-blake2b.html" href="Docs-wolfssl-manual-18-4-wolfcrypt-api-blake2b.html">Next Chapter</a></p>
</div>
</div>
</div>
<div id="id20" style="height: 25px; left: 35px; position: absolute; top: 27px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_19"><a class="class16" title="Docs-wolfssl-manual-18-2-wolfcrypt-api-arc4.html" href="Docs-wolfssl-manual-18-2-wolfcrypt-api-arc4.html">Previous Chapter</a></p>
</div>
</div>
</div>
<div id="id21" style="height: 25px; left: 323px; position: absolute; top: 27px; width: 125px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_125_25" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_7"><a class="class17" title="Docs-wolfssl-manual-toc.html" href="Docs-wolfssl-manual-toc.html">Table of Contents</a></p>
</div>
</div>
</div>
<div id="id22" style="height: 29px; left: 35px; position: absolute; top: 65px; width: 701px; z-index: 1; " class="style_SkipStroke shape-with-text">
<div class="text-content graphic_textbox_layout_style_default_External_701_29" style="padding: 0px; ">
<div class="graphic_textbox_layout_style_default">
<p style="padding-bottom: 0pt; padding-top: 0pt; " class="paragraph_style_20">Copyright 2017 wolfSSL Inc.  All rights reserved.</p>
</div>
</div>
</div>
</div>
</div>
</div>
 </body>

<!-- Mirrored from www.wolfssl.com/wolfSSL/Docs-wolfssl-manual-18-3-wolfcrypt-api-asn.html by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 17 Jan 2017 13:37:15 GMT -->
</html>
